Page({
  data: {
    statusBarHeight: 0,
    currentTab: 0, // 0: 积分加减规则, 1: 等级制度
    // 加分项
    addPoints: [
      { id: 1, item: '被添加的人', points: '+5' }
    ],
    // 减分项
    minusPoints: [
      { id: 1, item: '好友申请', points: '-10' },
      { id: 2, item: '发布活动', points: '-10' },
      { id: 3, item: '用户举报不实评论', points: '-20' },
      { id: 4, item: '活动违约被举报', points: '-30' }
    ],
    // 等级制度
    levels: [
      { id: 1, name: '刚玩儿', points: '0~299' },
      { id: 2, name: '会玩儿', points: '300' },
      { id: 3, name: '资深玩家', points: '600' },
      { id: 4, name: '大玩家', points: '1200' },
      { id: 5, name: '玩神', points: '3000' }
    ],
    // 特权
    privileges: [
      { level: '刚玩儿', content: '无' },
      { level: '会玩儿', content: '好友申请' },
      { level: '资深玩家', content: '免费好友申请3次/天+免费发布活动1次/天' },
      { level: '大玩家', content: '免费好友申请5次/天+免费发布活动2次/天' },
      { level: '玩神', content: '专属头像框+免费好友申请10次/天+免费发布活动5次/天' }
    ],
    // 积分充值
    recharge: [
      { amount: '10元', points: '100分' },
      { amount: '29元', points: '300分' },
      { amount: '45元', points: '500分' },
      { amount: '99元', points: '1200分' }
    ]
  },

  onLoad() {
    const windowInfo = wx.getWindowInfo();
    const navBarHeight = windowInfo.statusBarHeight + 44; // 导航栏总高度(状态栏+44px)
    this.setData({
      statusBarHeight: windowInfo.statusBarHeight,
      navBarHeight: navBarHeight
    });
  },

  onShow() {
    // 🔔 自动初始化通知组件
    const app = getApp();
    app.autoInitNotification();
  },

  // 切换tab
  switchTab(e) {
    const { index } = e.currentTarget.dataset;
    this.setData({
      currentTab: index
    });
  },

  // 返回
  goBack() {
    wx.navigateBack();
  }
});

